import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { AttemptCustomer } from '@libs/db/models/attempt.model';
import { IPaginationFormWithCondition } from 'types/requestParams';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';

@Injectable()
export class AttemptCustomerService {
  constructor(@InjectModel('AttemptCustomer') private readonly customerModel: Model<AttemptCustomer>) {

  }
  create(body: AttemptCustomer) {
    try {
      return 'ok'
    } catch (e) {
      if (e.status === 400) {
        throw new HttpException(e, HttpStatus.BAD_REQUEST)
      } else {
        throw new HttpException('服务器内部错误', HttpStatus.INTERNAL_SERVER_ERROR)
      }
    }
  }

  async findAll(body: IPaginationFormWithCondition) {
    try {
      return 'ok'
    } catch (e) {
      if (e.status === 400) {
        throw new HttpException(e, HttpStatus.BAD_REQUEST)
      } else {
        throw new HttpException('服务器内部错误', HttpStatus.INTERNAL_SERVER_ERROR)
      }
    }
  }

  async findOne(id: number) {
    try {
      return 'ok'
    } catch (e) {
      if (e.status === 400) {
        throw new HttpException(e, HttpStatus.BAD_REQUEST)
      } else {
        throw new HttpException('服务器内部错误', HttpStatus.INTERNAL_SERVER_ERROR)
      }
    }
  }

  async update(body: AttemptCustomer) {
    try {
      return 'ok'
    } catch (e) {
      if (e.status === 400) {
        throw new HttpException(e, HttpStatus.BAD_REQUEST)
      } else {
        throw new HttpException('服务器内部错误', HttpStatus.INTERNAL_SERVER_ERROR)
      }
    }
  }

  async remove(id: number) {
    try {
      return 'ok'
    } catch (e) {
      if (e.status === 400) {
        throw new HttpException(e, HttpStatus.BAD_REQUEST)
      } else {
        throw new HttpException('服务器内部错误', HttpStatus.INTERNAL_SERVER_ERROR)
      }
    }
  }
}
